]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensions/shared: Don't cache detected URL
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 13 Aug 2023 17:12:27 +0000 (19:12 +0200)
committerMarge Bot <marge-bot@gnome.org>
Mon, 14 Aug 2023 11:46:57 +0000 (11:46 +0000)
The translation functions we export from extension utils must
work with all extensions, not only the first that calls one
of the functions.

That means that we are back to examining a backtrace for every
function call unless an extension defined its own translation
functions with `import.meta.url`.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2887>

js/extensions/sharedInternals.js

index 7fed3812a23e60907d9d7c469b5ada3a2023398d..c9cb8e9c8e502710c01288d5d8cceb15ab7bd8bf 100644 (file)
@@ -218,10 +218,8 @@ export class GettextWrapper {
     }
 
     #lookupExtension(funcName) {
-        if (!this.#url)
-            this.#url = this.#detectUrl();
-
-        const extension = this.#extensionClass.lookupByURL(this.#url);
+        const url = this.#url ?? this.#detectUrl();
+        const extension = this.#extensionClass.lookupByURL(url);
         if (!extension)
             throw new Error(`${funcName} can only be called from extensions`);
         return extension;